package com.wohuijituan.whcsmerchant.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wohuijituan.whcsmerchant.R;
import com.wohuijituan.whcsmerchant.bean.TotalMoneyBean;
import com.wohuijituan.whcsmerchant.callback.TotalMoneyCallBack;
import com.wohuijituan.whcsmerchant.url.ParamsKey;
import com.wohuijituan.whcsmerchant.url.Urls;
import com.wohuijituan.whcsmerchant.utils.LogUtils;
import com.wohuijituan.whcsmerchant.utils.MyOkHttpUtils;
import com.wohuijituan.whcsmerchant.utils.MyRequestParams;

import okhttp3.Call;

/**
 * 说明：
 * 作者：朱世元
 * 时间： 2016/8/22 17:06
 * 版本：V1.0
 * 修改历史：
 */
public class CostSettlementActivity extends MyBaseActivity implements View.OnClickListener{
    public static final String TAG = "CostSettlementActivity";
    private TextView tvAccountMoney;
    private Button btnDrawMoney;
    private LinearLayout llIncomeRecord;
    private LinearLayout llDrawMoneyRecord;
    private ImageButton titleGoBack;
    private TextView titleName;
    private MyOkHttpUtils myOkHttpUtils;
    private MyRequestParams params;

    private void assignViews() {
        tvAccountMoney = (TextView) findViewById(R.id.tv_account_money);
        btnDrawMoney = (Button) findViewById(R.id.btn_draw_money);
        llIncomeRecord = (LinearLayout) findViewById(R.id.ll_income_record);
        llDrawMoneyRecord = (LinearLayout) findViewById(R.id.ll_draw_money_record);
        titleGoBack = (ImageButton) findViewById(R.id.title_go_back);
        titleName = (TextView) findViewById(R.id.title_name);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cost_settlement);
        assignViews();
        initDate();
        initView();
        initListener();
    }

    private void initView() {
        titleName.setText(R.string.cost_settlement);
        titleGoBack.setVisibility(View.VISIBLE);
    }

    private void initListener() {
        btnDrawMoney.setOnClickListener(this);
        titleName.setOnClickListener(this);
        llDrawMoneyRecord.setOnClickListener(this);
        llIncomeRecord.setOnClickListener(this);
        titleGoBack.setOnClickListener(this);
    }

    private void initDate() {
        myOkHttpUtils = new MyOkHttpUtils();
        params = new MyRequestParams();
    }
    private void drawMoneyRequest(){
        showDialog(ctx);
        String strUrl = Urls.TotalMoney;
        params.clear();;
        params.addStringRequest(ParamsKey.UserKey, myApplication.getUserKey());
        myOkHttpUtils.postRequest(strUrl, params, new TotalMoneyCallBack() {
            @Override
            public void onError(Call call, Exception e, int id) {
                dismissDialog();
                showToast(ctx, "网络出错,请检查网络是否连接!");
                LogUtils.e(TAG, e.getMessage());
            }

            @Override
            public void onResponse(TotalMoneyBean response, int id) {

            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_draw_money://提现按钮
                Intent intent = new Intent(this,DrawMoneyActivity.class);
                startActivity(intent);
                break;
            case R.id.ll_income_record://收支记录
                intent = new Intent(this,IncomeRecordActivity.class);
                startActivity(intent);
                break;
            case R.id.ll_draw_money_record://提现记录
                //查看提现记录操作
                intent = new Intent(this,DrawRecordActivity.class);
                startActivity(intent);
                break;
            case R.id.title_go_back://返回按钮
                onBackPressed();
                break;
        }
    }
}
